package com.example.qihuibao.utils

import com.example.qihuibao.enum.*

object EnumUtils {
    fun getStatus(status:String):Array<Status> {
        return when(status) {
            "0" -> arrayOf(Status.正常, Status.冻结)
            else -> arrayOf(Status.冻结, Status.正常)
        }
    }

    fun getMealStatus(status:String):Array<MealStatus> {
        return when(status) {
            "0" -> arrayOf(MealStatus.不开餐, MealStatus.开餐)
            else -> arrayOf(MealStatus.开餐, MealStatus.不开餐)
        }
    }

    fun getEnable(s:String, bit:Int):Boolean {
        val array = s.toCharArray()
        if (array.isNotEmpty() && array.size > bit-1) {
            return array[bit-1] == '1'
        }
        return false
    }

    fun getFlowType(s:String?): Array<FlowType> {
        return when(s) {
            "1" -> arrayOf(FlowType.客户确认, FlowType.自动, FlowType.客服确认, FlowType.客服_客户确认, FlowType.客户_客服确认)
            "2" -> arrayOf(FlowType.客服确认, FlowType.自动, FlowType.客户确认, FlowType.客服_客户确认, FlowType.客户_客服确认)
            "3" -> arrayOf(FlowType.客服_客户确认, FlowType.客户_客服确认, FlowType.自动, FlowType.客户确认, FlowType.客服确认)
            "4" -> arrayOf(FlowType.客户_客服确认, FlowType.自动, FlowType.客户确认, FlowType.客服确认, FlowType.客服_客户确认)
            else -> arrayOf(FlowType.自动, FlowType.客户确认, FlowType.客服确认, FlowType.客服_客户确认, FlowType.客户_客服确认)
        }
    }

    fun getOrderMode(s:String?): Array<OrderMode> {
        return when(s) {
            "1" -> arrayOf(OrderMode.点餐, OrderMode.套餐, OrderMode.简约, OrderMode.混合)
            "2" -> arrayOf(OrderMode.简约, OrderMode.套餐, OrderMode.点餐, OrderMode.混合)
            "3" -> arrayOf(OrderMode.混合, OrderMode.套餐, OrderMode.点餐, OrderMode.简约)
            else -> arrayOf(OrderMode.套餐, OrderMode.点餐, OrderMode.简约, OrderMode.混合)
        }
    }

    fun getChannelStd(status:String):Array<ChannelStd> {
        return when(status) {
            "1" -> arrayOf(ChannelStd.合并, ChannelStd.分开)
            else -> arrayOf(ChannelStd.分开, ChannelStd.合并)
        }
    }
}